import React, { Component } from 'react'
import Child from './Child'
class Life extends Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        };
    }
    //自定义函数
    handerAdd = () => {
        this.setState(
            {
                count:this.state.count + 1
            }
        )
    }
    handerAdd(){
        this.setState(
            {
                count:this.state.count+1
            }
        )
    }
    render() {
        return (
            <div>
                <p>React生命周期介绍</p>
                <button onClick={this.handerAdd}>点击一下</button>
                <button onClick={this.handerAdd.bind(this)}>点击一下</button>
                <p>{this.state.count}</p>
                <Child name={this.state.count}/>
            </div>
        )
    }
}
export default Life;